#include <SimpleDef.h>
#include <FileSystem/FAT32.h>

#define EOF (-1)

typedef struct __FileObject
{
    LPFileControlBlock lpFCB; /* 文件对应的控制块 */
    DWORD dwFilePointer; /* 文件指针 */
    DWORD dwCurrentCluster; /* 当前所处的簇 */
    struct __FileObject* lpNext;
} FileObject, *LPFileObject;

BOOL FCBIsDirectory(LPFileControlBlock lpFCB);
LPFileControlBlock MatchFCBByPath(LPCSTR lpszFileName);
LPFileObject SimpleCreateFile(LPCSTR lpszFileName, DWORD dwAttributes);
DWORD GetFirstSectorOfFAT32Cluster(LPFAT32BPBHEADER lpFAT32BPBHeader, DWORD dwClusterNum);
FAT32ENTRY GetFAT32Entry(const FAT32BPBHEADER* lpFAT32BPBHeader, DWORD dwIndex);
static inline BOOL IsClusterValid(FAT32ENTRY fat32entry)
{
    return fat32entry < FAT32_RESERVED;
}
BOOL SimpleReadFile(
    LPFileObject lpFileObj,
    LPVOID lpBuffer,
    DWORD nNumberOfBytesToRead,
    LPDWORD lpNumberOfBytesRead
);